﻿package lobby.exchangeddata
{
	/**
	 * ...
	 * @author Tom
	 */
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import lobby.constants.ConstData
	import lobby.events.LobbyEvent;
	
	public class BetStatusInfo extends EventDispatcher
	{
		public var pageNum:uint;
		public var addPage:Boolean = true;
		public var statusData:Array;
		
		public function BetStatusInfo()
		{
		
		}
		
		public function resultRecentBet(result:String):void
		{
			statusData = new Array();
			var temp:Array = result.split("&");
			this.pageNum = temp[0];
			var tempStr:String = temp[1].substr(ConstData.LEN_SUCCESS_RESULT, temp[1].length - 1);
			var temArr:Array = tempStr.split("*");
			var MAX_NUM_ROW:int = parseInt(temArr[0]);
			if (temArr.length == 0)
				return;
			// only get up to 99 pages	
			if (this.pageNum > 99)
			{
				this.pageNum = 99;
				temArr.splice(1, temArr.length - (99 * MAX_NUM_ROW * 10 + 1));
			}
			var index:int = 1;
			for (var i:int = 1; i <= MAX_NUM_ROW; i++)
			{
				var itemInfo:BetStatusItemInfo = new BetStatusItemInfo();
				
				itemInfo.setBetNo = temArr[index];
				itemInfo.setDateNo = temArr[index + 1];
				itemInfo.setTimeNo = temArr[index + 2];
				itemInfo.setTableNo = temArr[index + 3];
				itemInfo.setGameSetNo = temArr[index + 4];
				itemInfo.setBetCode = temArr[index + 5];
				itemInfo.setResultNo = temArr[index + 6];
				itemInfo.setAmountNo = temArr[index + 7];
				itemInfo.setWinNo = temArr[index + 8];
				itemInfo.setCommissionAmount = temArr[index + 9];
				index += 10;
				
				statusData.push(itemInfo);
			}
			dispatchEvent(new LobbyEvent(LobbyEvent.UPDATE_BET_STATUS, true));
		}
	}

}